package com.hfy.music.mapper;

import com.hfy.model.vo.MusicVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @ author 韩
 * time: 2024/6/7 17:56
 */
@Mapper
public interface DetailMusicMapper {
//    @Select("SELECT  music.*,  \n" +
//            "    (SELECT COUNT(*) FROM music_like WHERE music_like.music_id = music.id) AS `like`,\n" +
//            "    (SELECT COUNT(*) FROM music_comment WHERE music_comment.music_id = music.id) AS `comment` FROM music " +
//            "    WHERE id = #{id}")
    @Select("SELECT music.* FROM music WHERE id = #{musicId}")
    MusicVo queryMusicDetail(@Param("musicId") Integer musicId);

    @Select("SELECT * FROM `music_like` WHERE biz=#{biz} AND account=#{account} AND biz_id=#{musicId}")
    Integer queryMusicLikeByAccount(@Param("biz") Integer biz,@Param("musicId")Integer musicId,@Param("account") Long account);

    @Select("SELECT like_count FROM `like_count` WHERE biz=#{biz} AND biz_id=#{musicId}")
    Integer queryLikeCount(@Param("biz") Integer biz,@Param("musicId") Integer musicId);

    @Select("SELECT unlike_count FROM `like_count` WHERE biz=#{biz} AND biz_id=#{musicId}")
    Integer queryUnlikeCount(@Param("biz") Integer biz,@Param("musicId") Integer musicId);

    @Select("SELECT comment_count FROM `comment_count` WHERE biz=#{biz} AND biz_id=#{musicId}")
    Integer queryCommentCount(@Param("biz") Integer biz,@Param("musicId") Integer musicId);

    @Select("SELECT uncomment_count FROM `comment_count` WHERE biz=#{biz} AND biz_id=#{musicId}")
    Integer queryUncommentCount(@Param("biz") Integer biz,@Param("musicId") Integer musicId);

}
